<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--onclick点击事件，里面的内容可以是JavaScript代码（只是一行）或函数-->
<button onclick="choucha()">随机抽查</button>
<script>
    /*
        练习：实现一个随机班级人员抽查程序：
            （1）记录每个学员被抽到的次数
            （2）每一轮必须保证所有学员都抽中，才能进行下一轮
     */
    let array = ["周小龙","陈相伍","陈世杰","潘琪","黄衍秋","李清泉","吴文辉","黎燕","黄小婷","翁淋","王思晨","张万江","黄晓泰","黄柱源","刘立良",
        "覃颂雅","卓美秀","蒋扬臻","周永康","黎倍巧","何柳香","覃金雪","石小条","关家杰","黄以权","杨寅","陈孔珍","吴婷","宁敏","甘燚艳","曾柳玉",
        "廖孔娟","刘金澜","杨绵树","廖锦颖","黄圣泉","黄文华","谢天雪","陆锐兰","陆梦夏","梁桂妙","朱永贵","黄华森","张婷婷","雪奕娈","李昌相","容运南",
        "蒙智","阮积浩","陈泽深","卢炫天","黄宗灿","覃胜泰","昆庭","韦巍"];
    // 上面的字符串数组没有能力记录次数，所以需要转换为对象数组
    // 定义对象数组，有name和count属性
    let stus = [];
    // 给stus数组添加对象
    for (let i = 0; i < array.length; i++) {
        let obj = {}; // 创建学生对象
        obj.name = array[i];
        obj.count = 0;
        stus.push(obj);
    }

    function choucha() {
        // 随机抽查，范围是[0, stus.length - 1]
        let r = Math.floor(Math.random() * stus.length); // stus数组的索引
        stus[r].count++;
        console.log(stus);
    }
    choucha();
</script>
</body>
</html>